﻿using CommonTools;
using CommunityToolkit.Mvvm.ComponentModel;
using DataViews.Models;
using Main.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using System.Printing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace Main.Configs
{
    public partial class VoucherPrintConfig:ConfigBase<VoucherPrintConfig>
    {
        public VoucherPrintConfig()
        {
            
        }

        protected override void _DefaultInit()
        {
            //
            var filter_items = new[]
            {
                new {col="posting_date",display="记账日期" ,default_filter="",selected=true},
                new {col="account",display="科目名称" ,default_filter="",selected=true},
                new {col="against",display="对方科目" ,default_filter="",selected=true},
                new {col="debit",display="借方金额" ,default_filter="",selected=true},
                new {col="credit",display="贷方金额" ,default_filter="",selected=true},
                new {col="voucher_type",display="凭证类型" ,default_filter="",selected=true},
                new {col="voucher_no",display="凭证编号" ,default_filter="",selected=true},
                new {col="company",display="公司名称" ,default_filter="",selected=true},
            };
            
            foreach (var item in filter_items)
            {
                var filter = new FilterItem();
                filter.FieldName = item.col;
                filter.FieldDisplayName = item.display;
                filter.FilterString = item.default_filter;
                filter.Selected = item.selected;
                Filters.Add(filter);
            }


            //
            var display_fields = new[]
            {
                //""=不排序  "↑"=降序  "↓"=升序 注意：从表头看上下箭头
                new {col="posting_date",display="记账日期" ,orderby="↑",width=150},
                new {col="account",display="科目名称" ,orderby="",width=250},
                new {col="against",display="对方科目" ,orderby="",width=250},
                new {col="debit",display="借方金额" ,orderby="",width=150},
                new {col="credit",display="贷方金额" ,orderby="",width=150},
                new {col="voucher_type",display="凭证类型" ,orderby="",width=150},
                new {col="voucher_no",display="凭证编号" ,orderby="",width=150},
                new {col="company",display="公司名称" ,orderby="",width=200},
            };

            foreach (var item in display_fields)
            {
                DisplayField displayField = new DisplayField();
                displayField.FieldName = item.col;
                displayField.FieldDisplayName = item.display;
                displayField.OrderBy = item.orderby;
                displayField.Width = item.width;
                DisplayFields.Add(displayField);
            }

            

        }

        [ObservableProperty]
        ObservableCollection<FilterItem> filters=new ObservableCollection<FilterItem>();

        [ObservableProperty]
        ObservableCollection<DisplayField> displayFields = new ObservableCollection<DisplayField>();

        [ObservableProperty]
        int displayCountPerPage = 100;

        [ObservableProperty]
        string defaultFinanceManager = "金兰";

        [ObservableProperty]
        string defaultAccountingClerk = "孙钰茹";

        [ObservableProperty]
        string defaultReviewer = "金兰";

        [ObservableProperty]
        string defaultVoucherMaker = "孙钰茹";        

        [ObservableProperty]
        string? outputFolder = "d:\\打印凭证图片留存";

        [ObservableProperty]
        bool onlyNotYetPrinted = true;

        

        public int VoucherMaxRowCount { get; set; } = 5;

        public string PrintQueueName { get; set; } = "Brother DCP-L2550DW series";

        public PageMediaType PageMediaType { get; set; } = PageMediaType.Plain;

        public PageOrientation PageOrientation { get; set; }= PageOrientation.Portrait;

        public PageMediaSizeName PageMediaSizeName { get; set; } = PageMediaSizeName.ISOA4;

        public double PageWidth { get; set; } = 210.0 * 96 / 25.4;

        public double PageHeight { get; set; }= 297 * 96 / 25.4;


        //凭证尺寸
        public double VoucherWidth { get; set; } = 240;
        public double VoucherHeight { get; set; } = 140;

        


    }
}
